The present invention relates generally to frameworks for invoking methods in virtual computing machines. More specifically, the invention relates to frameworks for representing class files that facilitate the method invocation process within a virtual machine and to processes for creating such representations of a class file.
Recently, the Java™ programming environment has become quite popular. The Java™ programming language is an object-based high level programming language that is designed to be portable enough to be executed on a wide range of computers ranging from small devices (e.g., pagers, cell phones and smart cards) up to supercomputers. Computer programs written in the Java programming language (and other languages) may be compiled into Java virtual machine instructions (typically referred to as Java bytecodes) that are suitable for execution by a Java virtual machine implementation.
The Java virtual machine is commonly implemented in software by means of an interpreter for the Java virtual machine instruction set, but in general may be software, hardware, or both. A particular Java virtual machine implementation and corresponding support libraries, together constitute a Java™ runtime environment.
Computer programs in the Java programming language are arranged in one or more classes or interfaces (referred to herein jointly as classes or class files). Such programs are generally platform, i.e., hardware and operating system, independent. As such, these computer programs may be executed, unmodified, on any computer that is able to run an implementation of the Java™ runtime environment. A class written in the Java programming language is compiled to a particular binary format called the “class file format” that includes Java virtual machine instructions for the methods of a single class. In addition to the Java virtual machine instructions for the methods of a class, the class file format includes a significant amount of ancillary information that is associated with the class. The class file format (as well as the general operation of the Java virtual machine) is described in some detail in The Java Virtual Machine Specification by Tim Lindholm and Frank Yellin (ISBN 0-201-31006-6), which is incorporated herein by reference.
As described in The Java Virtual Machine specification, one of the structures of a standard class file is known as the “Constant Pool.”. The Constant Pool is a data structure that has several uses. One of the uses of the Constant Pool that is relevant to the present invention is that the Constant Pool contains the information that is needed to resolve each method that can be invoked by any of the methods within the class. FIG. 1 (which may be familiar to those skilled in the art) is a representation of a Constant Pool section of a class file that contains the information necessary to uniquely identify and locate a particular invoked method.
Generally, when a class file is loaded into the virtual machine, the virtual machines essentially makes a copy of the class file for its internal use. The virtual machine's internal copy is sometimes referred to as an “internal class representation.” In conventional virtual machines, the internal class representation is typically almost an exact copy of the class file and it replicates the entire Constant Pool. This is true regardless of whether multiple classes loaded into the virtual machine reference the same method and thus replicate some (or much) of the same Constant Pool information. Such replication may, of course, result in an inefficient use of memory resources. In some circumstances (particularly in embedded systems which have limited memory resources) this inefficient use of memory resources can be a significant disadvantage.
Additionally, conventional virtual machine interpreters decode and execute the virtual machine instructions (Java bytecodes) one instruction at a time during execution, e.g., “at runtime.” To invoke a method referenced by a Java bytecode, the virtual machine must make access the Constant Pool simply to identify the information necessary to locate and access the method to be invoked. Again, this is inefficient. Such inefficiencies tend to slow the performance of the virtual machine. Accordingly, improved frameworks for invoking methods in virtual machines such as Java virtual machines would be very useful.